package org.xiji.ChainOfResponsibility;

/**
 * 处理器测试类
 */
public class ChainOfResponsibilityMain {
    public static void main(String[] args) {
        //老师角色
        Teacher teacher = new Teacher();

        //导员角色
        Instructor instructor = new Instructor();

        //校长角色
        Principal principal = new Principal();

        System.out.println("===========================");
        /**
         * 请假关系   老师==>导员===>校长
         */
        System.out.println("正常流程请7天假");
        teacher.setNextHandler(instructor);
        instructor.setNextHandler(principal);
        //例如找老师请假七天
        int day = 7;
        teacher.handle(day);

        System.out.println("===========================");
        System.out.println("非正常流程请7天假");
        //找老师请假七天,导员不在，老师让你找校长
        /**
         * 请假关系 老师===>校长
         */
        teacher.setNextHandler(principal);
        teacher.handle(day);
        System.out.println("===========================");
        System.out.println("正常流程请15天假");
        //想请15天假
        int day2 = 15;
        //正常流程 找老师请假===>导员===>校长
        teacher.setNextHandler(instructor);
        instructor.setNextHandler(principal);
        teacher.handle(day2);

    }
}
